package com.lj.kdmadmin.modules.sites.controller;

import java.util.Arrays;
import java.util.Map;

import com.lj.kdmadmin.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lj.kdmadmin.modules.sites.entity.TKdsCtaegoryEntity;
import com.lj.kdmadmin.modules.sites.service.TKdsCtaegoryService;
import com.lj.kdmadmin.common.utils.PageUtils;
import com.lj.kdmadmin.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-07-09 15:17:35
 */
@RestController
@RequestMapping("sites/tkdsctaegory")
public class TKdsCtaegoryController {
    @Autowired
    private TKdsCtaegoryService tKdsCtaegoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sites:tkdsctaegory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tKdsCtaegoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sites:tkdsctaegory:info")
    public R info(@PathVariable("id") Long id){
        TKdsCtaegoryEntity tKdsCtaegory = tKdsCtaegoryService.selectById(id);

        return R.ok().put("tKdsCtaegory", tKdsCtaegory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sites:tkdsctaegory:save")
    public R save(@RequestBody TKdsCtaegoryEntity tKdsCtaegory){
        tKdsCtaegoryService.insert(tKdsCtaegory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sites:tkdsctaegory:update")
    public R update(@RequestBody TKdsCtaegoryEntity tKdsCtaegory){
        ValidatorUtils.validateEntity(tKdsCtaegory);
        tKdsCtaegoryService.updateAllColumnById(tKdsCtaegory);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sites:tkdsctaegory:delete")
    public R delete(@RequestBody Long[] ids){
        tKdsCtaegoryService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
